<template>
	<view>
		<button @click="callStorageFun(1)">setStorage</button>
		<button @click="callStorageFun(2)" type="primary" plain="true">getStorage</button>
		<button @click="callStorageFun(3)" type="primary">取消计时器</button>
		<button @click="callStorageFun(4)" type="warn" plain="true">取消计时器</button>
		<button @click="callStorageFun(5)" type="warn">取消计时器</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {

			}
		},
		methods: {
			callStorageFun(parm) {
				console.log("callStorageFun==> parm" + parm);
				switch (parm) {
					case 1:
						uni.setStorage({
							key: 'className',
							data: 'hzj',
							success() {
								console.log("UserName 存储成功");
							}
						});
						console.log("调用存储完成 ");
						break;
					case 2:
						uni.getStorage({
							key: 'Username',
							success: function(result) {
								console.log("读取UserName成功 result.data=" + result.data);
							},
							fail() {
								console.log("读取UswerName失败");
							}
						});
						break;
						case 3:
						uni.getStorageInfo({
							success:function(result){
								console.log("获取所有缓存字段：" +result.keys);
							}
						})
						break;
						case 4:
						uni.removeStorage({
							key:'UserName',
							success() {
								console.log("UserName 删除成功");
							}
						})
						break
				}
			}

		}
	}
</script>

<style>

</style>